package test01.way.c;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * @Author lzp
 * @Date 2024-03-19
 */
public class Test {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        Color c = new Color();
        FutureTask<Integer> redTask = new FutureTask<>(c);
        FutureTask<Integer> greenTask = new FutureTask<>(c);
        FutureTask<Integer> blueTask = new FutureTask<>(c);

        Thread t1 = new Thread(redTask);
        Thread t2 = new Thread(greenTask);
        Thread t3 = new Thread(blueTask);

        t1.start();
        t2.start();
        t3.start();

        Integer red = redTask.get();
        Integer green = greenTask.get();
        Integer blue = blueTask.get();

        System.out.println("红色:"+ red +" 绿色:"+ green +" 蓝色:" + blue);

    }
}
